/*
 * WantToBuyDetailGoodsHolder.java
 * business
 *
 * Created by ChenTao on 2017/5/26.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.text.SpannableString;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Goods;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.utils.ImageLoader;
import com.yidiandao.business.utils.TextRenderUtils;
import com.yidiandao.business.utils.UIUtils;

/**
 * 发现-求购详情-类似商品信息-ViewHolder
 * <p>
 * Created by ChenTao(chentao7v@gmail.com) on 2017-05-26 14:06
 */
public class WantToBuyDetailGoodsHolder extends ViewHolder {

    private ImageView ivShopLogo;
    private TextView tvShopName;
    private ImageView ivGoodsImage;
    private TextView tvGoodsName;
    private TextView tvGoodsPrice;
    public View root;

    @Override
    protected void initView(View rootView) {
        root = rootView;
        ivShopLogo = (ImageView) rootView.findViewById(R.id.iv_shop_logo);
        tvShopName = (TextView) rootView.findViewById(R.id.tv_shop_name);
        ivGoodsImage = (ImageView) rootView.findViewById(R.id.iv_goods_image);
        tvGoodsName = (TextView) rootView.findViewById(R.id.tv_goods_name);
        tvGoodsPrice = (TextView) rootView.findViewById(R.id.tv_goods_price);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_want_to_buy_detail_goods;
    }

    public void refreshUI(Goods goods) {
        ImageLoader.loadImage(mContext, ivShopLogo, goods.getShopLogo());
        ImageLoader.loadImage(mContext, ivGoodsImage, goods.getGoodsThumb());

        tvShopName.setText(goods.getSupplierName());
        tvGoodsName.setText(goods.getGoodsName());

        SpannableString beautyPrice = TextRenderUtils.getBeautyPrice(goods.getGoodsPrice() + "", goods.getGoodsUnit(), UIUtils.dp2px(18), UIUtils.dp2px(14));
        tvGoodsPrice.setText(beautyPrice);
    }
}
